/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.una.informatica.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MARTINCHO
 */
@Entity
@Table(name = "mediciones")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Mediciones.findAll", query = "SELECT m FROM Mediciones m"),
    @NamedQuery(name = "Mediciones.findByIdMedicion", query = "SELECT m FROM Mediciones m WHERE m.idMedicion = :idMedicion"),
    @NamedQuery(name = "Mediciones.findByValor", query = "SELECT m FROM Mediciones m WHERE m.valor = :valor")})
public class Mediciones implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_medicion")
    private Long idMedicion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "valor")
    private String valor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idMedicion")
    private Collection<Historial> historialCollection;
    @JoinColumn(name = "id_parametro", referencedColumnName = "id_parametro")
    @ManyToOne(optional = false)
    private Parametros idParametro;

    public Mediciones() {
    }

    public Mediciones(Long idMedicion) {
        this.idMedicion = idMedicion;
    }

    public Mediciones(Long idMedicion, String valor) {
        this.idMedicion = idMedicion;
        this.valor = valor;
    }

    public Long getIdMedicion() {
        return idMedicion;
    }

    public void setIdMedicion(Long idMedicion) {
        this.idMedicion = idMedicion;
    }

    public String getValor() {
        return valor;
    }

    public void setValor(String valor) {
        this.valor = valor;
    }

    @XmlTransient
    public Collection<Historial> getHistorialCollection() {
        return historialCollection;
    }

    public void setHistorialCollection(Collection<Historial> historialCollection) {
        this.historialCollection = historialCollection;
    }

    public Parametros getIdParametro() {
        return idParametro;
    }

    public void setIdParametro(Parametros idParametro) {
        this.idParametro = idParametro;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMedicion != null ? idMedicion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Mediciones)) {
            return false;
        }
        Mediciones other = (Mediciones) object;
        if ((this.idMedicion == null && other.idMedicion != null) || (this.idMedicion != null && !this.idMedicion.equals(other.idMedicion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.informatica.entidades.Mediciones[ idMedicion=" + idMedicion + " ]";
    }
    
}
